/**
 * @author dkochelaev
 */
package net.fdukedom.epicurus.domain.util;

import net.fdukedom.epicurus.domain.entity.LogEntry;
import org.hibernate.Session;

/**
 * Logging helper.
 *
 * @author Dmitry Y. Kochelaev
 */
public final class LogHelper {

    /**
     * The only instance of the class.
     */
    private static final LogHelper instance = new LogHelper();

    /**
     * Default constructor.
     */
    private LogHelper() {
        //this is an utility class only one instance is allowed
    }

    /**
     * Returns the only instance of the class.
     *
     * @return the only instance of the class
     */
    public static LogHelper getInstance() {
        return instance;
    }

    /**
     * Saves log entry record in database.
     *
     * @param entry entry to save
     */
    public synchronized void saveLogEntry(LogEntry entry) {
        Session session = HibernateUtil.getSession();
        session.save(entry);
    }
}
